/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Liste des modules pour les modules du bot ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Auteur: Thaeron
Projet: NewSyndrome
Licence: GPL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include "NewSyndrome.h"

module_list *
add_element_module_list (module_list * ml, module * w)
{
  module_list *h;
  if (w == NULL)
    return ml;
  h = (module_list *) malloc (sizeof (module_list));
  h->next = ml;
  h->auteur = (char *) malloc (strlen (w->auteur) + 1);
  strcpy (h->auteur, w->auteur);
  h->name = (char *) malloc (strlen (w->name) + 1);
  strcpy (h->name, w->name);
  h->version = (char *) malloc (strlen (w->version) + 1);
  strcpy (h->version, w->version);
  h->description = (char *) malloc (strlen (w->description) + 1);
  strcpy (h->description, w->description);
  h->ident = (char *) malloc (strlen (w->ident) + 1);
  strcpy (h->ident, w->ident);
  return h;
}

void
free_module_list (module_list * ml)
{
  module_list *runner, *m;
  for (runner = ml; runner != NULL; runner = m)
    {
      m = runner->next;
      free (runner->auteur);
      free (runner->ident);
      free (runner->description);
      free (runner->name);
      free (runner->version);
      free (runner);
    }
}
